//
//  YKPerformanceExchangeItemCell.m
//  YunKang
//
//  Created by leoking870 on 2017/10/15.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKPerformanceExchangeItemCell.h"
#import "YKDashView.h"
@interface YKPerformanceExchangeItemCell ()
@property (weak, nonatomic) IBOutlet UILabel *exchangeNumberLabel;
@property (weak, nonatomic) IBOutlet UILabel *exchangeCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *exchangeDateLabel;
@property (weak, nonatomic) IBOutlet UILabel *exchangeStateLabel;

@end


@implementation YKPerformanceExchangeItemCell
@dynamic tableViewItem;

- (void)cellLoadSubViews {
    [super cellLoadSubViews];
    self.exchangeNumberLabel.tf_weight = 1;
    self.exchangeCountLabel.tf_weight = 1;
    self.exchangeDateLabel.tf_weight = 1;
    self.exchangeStateLabel.tf_weight = 1;
    self.exchangeNumberLabel.textAlignment = NSTextAlignmentCenter;
    self.exchangeCountLabel.textAlignment = NSTextAlignmentCenter;
    self.exchangeDateLabel.textAlignment = NSTextAlignmentCenter;
    self.exchangeStateLabel.textAlignment = NSTextAlignmentCenter;
    [@[self.exchangeNumberLabel, self.exchangeCountLabel,self.exchangeDateLabel, self.exchangeStateLabel] mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.top.equalTo(self.contentView.mas_top).offset(11);
    }];
    
    [@[self.exchangeNumberLabel, self.exchangeCountLabel,self.exchangeDateLabel, self.exchangeStateLabel] mas_alignWeightlyAlongAxis:MASAxisTypeHorizontal
                                                                                                             fixedSpace:@8
                                                                                                              leadingTo:self.contentView.mas_leading
                                                                                                              leadSpace:13
                                                                                                             trailingTo:self.contentView.mas_trailing
                                                                                                              tailSpace:13];
    
    YKDashView* dashView = [[YKDashView alloc]init];
    dashView.lineWidth = .5f;
    dashView.lineColor = [UIColor tf_colorWithHexString:@"#d4d4d4"];
    dashView.dashLineLength = 3;
    [self addSubview:dashView];
    [dashView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.bottom.trailing.equalTo(self);
        make.height.mas_equalTo(1);
    }];
}

- (void)cellWillAppear {
    [super cellWillAppear];
    
    self.exchangeNumberLabel.text = self.tableViewItem.model.APPLY_CODE;
    self.exchangeCountLabel.text = self.tableViewItem.model.EXCHANGE_POINT;
    self.exchangeDateLabel.text = self.tableViewItem.model.APPLY_DATE;
    //0 ：未处理、1： 审批中、2： 已通过 3： 被驳回
    if ([self.tableViewItem.model.APPLY_STATUS isEqualToString:@"0"]) {
        self.exchangeStateLabel.text = @"未处理";
    }
    else if ([self.tableViewItem.model.APPLY_STATUS isEqualToString:@"1"]) {
        self.exchangeStateLabel.text = @"审批中";
    }
    else if ([self.tableViewItem.model.APPLY_STATUS isEqualToString:@"2"]) {
        self.exchangeStateLabel.text = @"已通过";
    }
    else if ([self.tableViewItem.model.APPLY_STATUS isEqualToString:@"3"]) {
        self.exchangeStateLabel.text = @"被驳回";
    }
    else if ([self.tableViewItem.model.APPLY_STATUS isEqualToString:@"4"]) {
        self.exchangeStateLabel.text = @"被退回";
    }
}

@end
